<h1>Отчёт по продуктам</h1>
	<div style="width:100%">
		<div class="table_body">
			<form id="filter" method="post" action="/backend/reports/product/" onsubmit="return false;">
				<div class="filter_form" style="margin-bottom: 10px;">
					<h3>фильтр</h3>
				    <label for="date_from">дата с:</label> <input type="text" id="date_from" name="filter[date_from]" value="{$filter_date_from}" readonly="readonly"> 
				    <img src="{$fvConfig->get('dir_web_root')}img/calendar_delete.png" width="16" height="16" border="0" class="dateselector_clear" title="очистить дату" onclick="$('date_from').value='';">
				    <img src="{$fvConfig->get('dir_web_root')}img/calendar.png" width="16" height="16" border="0" class="dateselector" id="date_from_pick" title="выбор даты">
				    <label for="date_to" style="margin-left: 20px;">дата по:</label> <input type="text" id="date_to" name="filter[date_to]" value="{$filter_date_to}"> 
				    <img src="{$fvConfig->get('dir_web_root')}img/calendar_delete.png" width="16" height="16" border="0" class="dateselector_clear" title="очистить дату" onclick="$('date_to').value='';">
				    <img src="{$fvConfig->get('dir_web_root')}img/calendar.png" width="16" height="16" border="0" class="dateselector" id="date_to_pick" title="выбор даты">
				    <label for="product_id" style="margin-left: 20px;">продукт:</label>
    				{html_options name=filter[product_id] id=product_id options=$ProductManager->htmlSelect('title', 'выберите продукт') selected=$filter_product_id style="width: 150px; float: left; display: block;"}
				    <div class="operation">
				        <a href="javascript:void(0);" onclick="$('clear').value = 1; window.sendForm.bind($('filter'), null, $('filter').readAttribute('action')).call();" class="delete    ">очистить</a>
				        <a href="javascript:void(0);" onclick="$('clear').value = ''; window.sendForm.bind($('filter'), null, $('filter').readAttribute('action')).call();" class="accept">применить</a>
				        <div style="clear: both;"></div>
				    </div>
				    <input type="hidden" id="clear" name="filter[_clear]" value="">
				</div>
			</form>
			{if $Report}
			<table class="text">
				{foreach item=r from=$Report key=k}
				<tr>
					<th colspan=5>Продукт "{$r.title|stripslashes}": заказов {$r.count} на сумму {$r.total}грн.</th>
	            </tr>
	            <tr>
	            	<th>Номер заказа</th>
	            	<th>Дата заказа</th>
	            	<th>Количество</th>
					<th>Сумма</th>
					<th>&nbsp;</th>
	            </tr>
	            {foreach from=$r.orders item=o key=key}
	            <tr>
	            	<th>{$key}</th>
	            	<td>{$o.date}</td>
	            	<td>{$o.count}шт.</td>
					<td>{$o.total}грн.</td>
					<td><a href="{$fvConfig->get('dir_web_root')}orders/show/?id={$key}" onclick="go('{$fvConfig->get('dir_web_root')}orders/show/?id={$key}'); return false;" class="link">просмотреть заказ</a></td>
	            </tr>
	            {/foreach}
	            <tr>
	            	<td colspan=5>&nbsp;</th>
	            </tr>
	            <tr>
					<td colspan=5><a href="javascript:void(0);" onclick="window.open('{$fvConfig->get('dir_web_root')}reports/download/?type=product');" class="link">Скачать файл</a></td>
				</tr>
				{/foreach}
			</table>
			{elseif (empty($filter_date_to) || empty($filter_date_from) || empty($filter_product_id))}
			<table class="text">
				<tr><td align="center">Заполните форму выше</td></tr>
			</table>
			{else}
			<table class="text">
				<tr><td align="center">Данные по указанным Вами параметрам не найдены</td></tr>
			</table>
			{/if}
		</div>
	</div>
	{literal}
<script>
    Calendar.setup({
        inputField : "date_from",
        ifFormat : "%Y-%m-%d 00:00:00",
        button : "date_from_pick",
        align : "Bl",
        firstDay: 1,
        showsTime: false,
        singleClick : true
    });
    Calendar.setup({
        inputField : "date_to",
        ifFormat : "%Y-%m-%d 23:59:59",
        button : "date_to_pick",
        align : "Bl",
        firstDay: 1,
        showsTime: false,
        singleClick : true
    });
</script>
{/literal}